home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 011 / brutil.arc / MLU.ASM < prev    next >
Encoding:
Assembly Source File  |  1987-09-04  |  2.0 KB  |  102 lines

  1. BUFLEN    EQU    32768        ; buffer length, alter to taste
  2.  
  3. CR    EQU    0DH        ; ASCII carriage return
  4. LF    EQU    0AH        ; ASCII line feed
  5.  
  6.                 ; DOS 2.x pre-defined handles
  7. STDIN    EQU    0        ; standard input file
  8. STDOUT    EQU    1        ; standard output file
  9. STDERR    EQU    2        ; standard error file
  10.  
  11. CSEG    SEGMENT PARA PUBLIC 'CODE'
  12.  
  13.     ASSUME    CS:CSEG,DS:CSEG
  14.  
  15.     ORG    100H        ; start .COM at 100H
  16.  
  17. MLU:
  18. MLU3:    MOV    AH,3FH        ; read standard input.
  19.     MOV    BX,STDIN
  20.     MOV    CX,BUFLEN
  21.     MOV    DX,OFFSET (BUFFER)
  22.     INT    21H
  23.     JC    MLU4        ; JUMP, ERROR.
  24.     MOV    NCHAR,AX    ; save length of read.
  25.     CMP    AX,0        ; nothing read in?
  26.     JNE    MLU4A        ; if not end of file, skip exit.
  27. MLU4:
  28.     MOV    AX,4C00H    ; exit with return code=0.
  29.     INT    21H
  30. MLU4A:    MOV    SI,OFFSET (BUFFER)
  31.     MOV    DI,SI
  32.     MOV    CX,NCHAR
  33. MLU5:    LODSB
  34.     CMP    AL,CR
  35.     JZ    TURNOF
  36.     CMP    AL,';'
  37.     JZ    TURNON
  38.     CMP    AL,'"'
  39.     JZ    TOGGLE
  40.     CMP    AL,"'"
  41.     JZ    TOGGLE
  42.     CMP    BYTE PTR MODE,0
  43.     JNZ    NOMASK
  44.     CMP    AL,'A'+32
  45.     JC    NOMASK
  46.     CMP    AL,'Z'+33
  47.     JNC    NOMASK
  48.     AND    AL,5FH
  49. NOMASK: STOSB
  50.     LOOP    MLU5
  51.     JMP    MLU4B
  52. TOGGLE: CMP    BYTE PTR MODE,';'
  53.     JZ    NOMASK
  54.     CMP    BYTE PTR MODE,0
  55.     JZ    SETIT
  56.     CMP    MODE,AL
  57.     JNZ    NOMASK
  58. SETIT:    XOR    MODE,AL
  59.     JMP    NOMASK
  60. TURNON: CMP    BYTE PTR MODE,0
  61.     JNZ    NOMASK
  62.     MOV    MODE,AL
  63.     JMP    NOMASK
  64. TURNOF: MOV    BYTE PTR MODE,0
  65.     JMP    NOMASK
  66. MLU4B:    MOV    AH,40H        ; now write to standard output...
  67.     MOV    BX,STDOUT
  68.     MOV    CX,NCHAR
  69.     MOV    DX,OFFSET (BUFFER)
  70.     INT    21H
  71.     JC    MLU7        ; jump, write failed.
  72.     CMP    AX,NCHAR
  73.     JNE    MLU7        ; jump, write failed.
  74.     JMP    MLU3        ; read again until end of file.
  75.  
  76. MLU7:    MOV    DX,OFFSET ERR2    ; print "Disk is full".
  77.     MOV    CX,OFFSET ERR2LEN
  78.     MOV    AH,40H        ; display error message and exit.
  79.     MOV    BX,STDERR
  80.     INT    21H
  81.     MOV    AX,4C02H
  82.     INT    21H
  83. NCHAR    DW    0        ; number of chars actually input.
  84. MODE    DB    0        ; current mode indicator
  85.  
  86. ERR2    DB    CR,LF
  87.     DB    'tee: Disk is full.'
  88.     DB    CR,LF
  89. ERR2LEN EQU    (THIS BYTE)-(OFFSET ERR2)
  90.  
  91. BUFFER    LABEL    BYTE        ; data is read here from
  92.                 ; standard input
  93.  
  94. CSEG    ENDS
  95.  
  96.     END    MLU
  97. N EQU    (THIS BYTE)-(OFFSET ERR2)
  98.  
  99. BUFFER    LABEL    BYTE        ; data is read here from
  100.                 ; standard input
  101.  
  102. CSEG    END